﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Hospital
{
    public partial class MainForm : Form
    {
        public delegate void PatientSearchHandler(int id,string name);
        public MainForm()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
            TitleUserControl titleUserControl = new TitleUserControl();
            this.plMain.Controls.Add(titleUserControl);
        }

        private void miSearchPatient_Click(object sender, EventArgs e)
        {
            openPatientSearchUserControl();
        }

        private void openPatientSearchUserControl()
        {
            if (this.plMain.Controls.Count > 1)
            {
                this.plMain.Controls.RemoveAt(1);
            }
           // this.Height = 300;
           // this.Width = 400;
            PatientSearchUserControl patientSearchUserControl = new PatientSearchUserControl();
            patientSearchUserControl.patientSearchEvent += new PatientSearchHandler(this.PatientSearchCallback);
            this.plMain.Controls.Add(patientSearchUserControl);
        }

        private void PatientSearchCallback(int id,string name)
        {
            this.plMain.Controls.RemoveAt(1);
           // this.Height = 768;
           // this.Width = 1024;
            
            PatientUserControl patientUserControl = new PatientUserControl(id,name);
            this.plMain.Controls.Add(patientUserControl);
        }

        private void miAddPatient_Click(object sender, EventArgs e)
        {
            openPatientUserControl();
        }
        private void openPatientUserControl()
        {
            if (this.plMain.Controls.Count > 1)
            {
                this.plMain.Controls.RemoveAt(1);
            }
          //  this.Height = 768;
          //  this.Width = 1024;
            PatientUserControl patientUserControl = new PatientUserControl();
            //patientSearchUserControl.patientSearchEvent += new PatientSearchHandler(this.PatientSearchCallback);
            this.plMain.Controls.Add(patientUserControl);
        }

        private void miExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
